package com.zgxl.common.util;

/**
 * @author pumbaa
 * @since 1.0
 */
public class AjaxResponse {

    /**
     * 是否成功
     */
    private Boolean success;
    /**
     * 提示信息
     */
    private String msg;
    /**
     * 返回代码
     */
    private Integer code;
    /**
     * 返回内容
     */
    private Object append;

    private AjaxResponse(Boolean success, String msg, Integer code, Object append) {
        this.success = success;
        this.msg = msg;
        this.code = code;
        this.append = append;
    }

    public Boolean getSuccess() {
        return success;
    }

    public void setSuccess(Boolean success) {
        this.success = success;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public Integer getCode() {
        return code;
    }

    public void setCode(Integer code) {
        this.code = code;
    }

    public Object getAppend() {
        return append;
    }

    public void setAppend(Object append) {
        this.append = append;
    }

    public static AjaxResponse ajaxSuccess(String msg, Object append) {
        return new AjaxResponse(true, msg, 1, append);
    }
    public static AjaxResponse ajaxSuccess(Object append) {
        return new AjaxResponse(true, "操作成功", 1, append);
    }
    public static AjaxResponse ajaxSuccess(String  msg) {
        return new AjaxResponse(true, msg, 1, null);
    }
    public static AjaxResponse ajaxSuccess() {
        return new AjaxResponse(true, "操作成功", 1, null);
    }

    public static AjaxResponse ajaxFailure(String msg, Object append) {
        return new AjaxResponse(false, msg, 0, append);
    }
    public static AjaxResponse ajaxFailure(Object append) {
        return new AjaxResponse(false, "操作失败", 0, append);
    }
    public static AjaxResponse ajaxFailure() {
        return new AjaxResponse(false, "操作失败", 0, null);
    }
    public static AjaxResponse ajaxFailure(String msg) {
        return new AjaxResponse(false, msg, 0, null);
    }
}
